<template>
  <div class="common-layout">
    <el-container>
      <el-aside width="200px">
        <el-menu
          default-active="2"
          class="el-menu-vertical-demo"
          router
          v-for="(item, i) in menu_list" :key="i"
        >
          <el-sub-menu :index="String(i)">
            <template #title>
              <!-- <el-icon><location /></el-icon> -->
              <span>{{item.name}}</span>
            </template>

            <el-menu-item-group v-for="(item, i) in item.children" :key="i">
              <el-menu-item :index="item.path">{{item.name}}{{item.path}}</el-menu-item>
            </el-menu-item-group>
          </el-sub-menu>
        </el-menu>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </div>
</template>

<script>
import {get_menu} from "@/utils/api"
import teacher from "@/components/management/teacher.vue"
import school from "@/components/management/school.vue"
export default {
    name: "home",
    components:{
      teacher,
      school
    },
    data(){
      return{
        menu_list: [],
      }
    },
    mounted(){
      get_menu().then(resp=>{
        console.log("获取成功", resp)
        this.menu_list = resp.data.data

      }).catch(err=>{
        console.log("获取失败", err)
      })
    }
}
</script>

<style>

</style>